/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.renren.controller;

import io.renren.annotation.Login;
import io.renren.annotation.LoginUser;
import io.renren.common.utils.R;
import io.renren.entity.UserEntity;
import io.renren.oss.service.SysConfigService;
import io.renren.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 测试接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@Slf4j
@RestController
@RequestMapping("/api")
@Api(tags = "测试接口")
public class ApiTestController {
    @Autowired
    private EslWorkingService eslWorkingService;
    @Autowired
    private SysDictService sysDictService;

    @Autowired
    private ApplicationService applicationService;

    @Autowired
    private RoomService roomService;

    @Autowired
    private SysConfigService sysConfigService;

    @Autowired
    private EslContentService eslContentService;

    @Autowired
    private RoomEslService roomEslService;

    @Login
    @GetMapping("userInfo")
    @ApiOperation(value = "获取用户信息", response = UserEntity.class)
    public R userInfo(@ApiIgnore @LoginUser UserEntity user) {
        return R.ok().put("user", user);
    }

    @Login
    @GetMapping("userId")
    @ApiOperation("获取用户ID")
    public R userInfo(@ApiIgnore @RequestAttribute("userId") Integer userId) {
        return R.ok().put("userId", userId);
    }

    @GetMapping("notToken")
    @ApiOperation("忽略Token验证测试")
    public R notToken() {
        return R.ok().put("msg", "无需token也能访问。。。");
    }

    @GetMapping("test")
    public R test(String twoCharatersName) {

//        String name = StrUtils.nameAutoFill(twoCharatersName);

        eslContentService.autoRefreshRoomApplicationEsl(162L);

        return R.ok();
    }


}
